import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/view/layout/index.vue'
import Layout2 from '@/view/layout/indexFull.vue'
import plantRouter from './modules/plant'
import userRouter from './modules/user'
import systemRouter from './modules/system'

export const menus = [
  // {
  //   path: 'index',
  //   name: 'Index',
  //   hidden:false,
  //   meta: {title: '首页',icon: 'odometer'},
  //   component: () => import('@/view/dashboard/index.vue'),
  // },
  
  ...plantRouter,
  ...userRouter,
  ...systemRouter
]

export const routes = [
  {
    path: "/full",
    name: "layout2",
    meta: {title: "layout2",icon: 'odometer'},
    hidden:false,
    redirect: '/full/farm',
    component: Layout2,
    children:[
      {
        path: 'farm',
        name: 'Farm',
        hidden:false,
        meta: {title: '我的农场',icon: 'odometer'},
        component: () => import('@/view/farm/index.vue'),
      },
      {
        path: 'massif',
        name: 'Massif',
        hidden:false,
        redirect:'/full/massif/index',
        meta: {title: '地块管理',icon: 'odometer'},
        component: () => import('@/view/massif/tm.vue'),
        children:[
          {
            path: 'index',
            name: 'Massif-Index',
            hidden:false,
            meta: {title: '地块管理'},
            component: () => import('@/view/massif/index/index.vue'),
          },
          {
            path: 'farm',
            name: 'Massif-Farm',
            hidden:false,
            meta: {title: '农场地块'},
            component: () => import('@/view/massif/farm/index.vue'),
          },
          {
            path: 'detail',
            name: 'Massif-Detail',
            hidden:false,
            meta: {title: '地块详情'},
            component: () => import('@/view/massif/detail/index.vue'),
          },
          {
            path: 'add',
            name: 'Massif-Add',
            hidden:false,
            meta: {title: '新增地块'},
            component: () => import('@/view/massif/add/index.vue'),
          },
        ]
      },
      {
        path: 'weather',
        name: 'Weather',
        hidden:false,
        meta: {title: '气象服务',icon: 'odometer'},
        component: () => import('@/view/weather/index.vue'),
      },
      {
        path: 'crop',
        name: 'Crop',
        hidden:false,
        meta: {title: '作物长势',icon: 'odometer'},
        component: () => import('@/view/crop/index.vue'),
      },
      {
        path: 'record',
        name: 'Record',
        hidden:false,
        meta: {title: '农事记录',icon: 'odometer'},
        component: () => import('@/view/record/index.vue'),
      }
    ]
  },
  {
    path: "/",
    name: "layout",
    meta: {title: "layout",icon: 'odometer'},
    hidden:false,
    redirect: '/full/farm',
    component: Layout,
    children:menus
  },
  {
    path: '/login',
    name: 'Login',
    hidden:true,
    component: () => import('@/view/login/index.vue'),
    meta: { title: '登录' }
  },
  { 
    path: '/404',
    name: '404',
    hidden:true,
    component: () => import('@/view/error/index.vue'),
    meta: { title: '404' }
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
